package com.clone.surpassli.clone_cloudreader.ui.menu;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.clone.surpassli.clone_cloudreader.R;
import com.clone.surpassli.clone_cloudreader.base.BaseActivity;
import com.clone.surpassli.clone_cloudreader.databinding.ActivityAboutBinding;
import com.clone.surpassli.clone_cloudreader.ui.common.WebViewActivity;
import com.clone.surpassli.clone_cloudreader.utils.PerfectClickListener;

/**
 * Created by SurpassLi on 2017/9/30.
 * NavAboutActivity
 */

public class NavAboutActivity extends BaseActivity<ActivityAboutBinding>{
    private RelativeLayout mCheckUpdateRelativeLayout;
    private RelativeLayout mUpdateLogRelativeLayout;
    private RelativeLayout mGiveStartRelativeLayout;
    private TextView mCodeHome;
    private TextView mDouBanProtocol;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
        showContentView();
        setTitle("关于仿云阅");
        mBindingView.tvAboutVersion.setText("当前版本 V1.0.0");
        initId();
        initListener();
    }

    private void initListener() {
        mCheckUpdateRelativeLayout.setOnClickListener(listener);
        mUpdateLogRelativeLayout.setOnClickListener(listener);
        mGiveStartRelativeLayout.setOnClickListener(listener);
        mCodeHome.setOnClickListener(listener);
        mDouBanProtocol.setOnClickListener(listener);
    }

    private void initId() {
        mCheckUpdateRelativeLayout = mBindingView.elAboutUpdateLog;
        mUpdateLogRelativeLayout = mBindingView.elAboutUpdateLog;
        mGiveStartRelativeLayout = mBindingView.elAboutGiveStart;
        mCodeHome = mBindingView.tvAboutCodeHome;
        mDouBanProtocol = mBindingView.tvAboutDouban;
    }

    private PerfectClickListener listener = new PerfectClickListener() {
        @Override
        protected void onNoDoubleClick(View v) {
            String url = null;
              switch (v.getId()){
                  case R.id.el_about_check_update:
                      break;
                  case R.id.el_about_update_log:
                      break;
                  case R.id.el_about_give_start:
                      break;
                  case R.id.tv_about_code_home:
                      break;
                  case R.id.tv_about_douban:
                      url = "https://developers.douban.com/wiki/?title=terms";
                      break;
              }
            WebViewActivity.loadUrl(v.getContext(),url,"加载中...");
        }
    };

    public static void start(Context mContext){
        mContext.startActivity(new Intent(mContext,NavAboutActivity.class));
    }
}